package com.service.single.example.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public enum AsyncFileType {

    RELATED_CORP(1, "关联方-法人"),
    RELATED_PERSON(2, "关联方-自然人"),
    CORRELATION(3, "关联关系"),
    RELATED_FINANCE(4, "金融产品"),
    REPORT_CREDIT(5, "银行季报-授信明细表"),
    REPORT_LOAD(6, "银行季报-用信明细表"),
    REPORT_NONLOAD(7, "银行季报-非授信明细表"),
    REPORT_TRANSBANLACE(8, "银行季报-关联交易余额表"),
    REPORT_INSURANCE(20, "保险单一法人资金运用关联交易统计表"),
    REPORT_INSURANCE_LIST(21, "保险关联交易明细表"),
    REPORT_INSURANCE_COUNT(22, "资金运用关联交易统计表"),
    REPORT_SINGLE(30, "单笔关联交易"),
    REPORT_BANK_RELATION(31, "银行外部图谱"),
    REPORT_NO_BANK_RELATION(32, "非银外部图谱"),
    REPORT_INSURANCE_RELATION(33, "保险外部图谱"),
    REPORT_TRUST_RELATION(34, "信托外部图谱"),
    REPORT_FINACIAL_RELATION(35, "金融资管外部图谱"),
    REPORT_ORG_RELATION(36, "法人关联方"),
    REPORT_PSN_RELATION(37, "自然人关联方");

    private Integer code;
    private String desc;

    private final static Map<Integer, AsyncFileType> TYPE_MAP = new HashMap<>();

    AsyncFileType(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static AsyncFileType getByCode(Integer code) {
        return TYPE_MAP.get(code);
    }

    static {
        AsyncFileType[] types = values();
        Map<Integer, AsyncFileType> map = Arrays.stream(types).collect(Collectors.toMap(AsyncFileType::getCode, Function.identity()));
        TYPE_MAP.putAll(map);
    }

    public Integer getCode() {
        return this.code;
    }

    public String getDesc() {
        return this.desc;
    }

}
